package com.scedu.service.Impl;

import com.scedu.entity.User;
import com.scedu.repository.UserRepository;
import com.scedu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;

@Service //业务层
@Transactional //事务控制
public class UserServiceImpl implements UserService {
    @Autowired
    UserRepository userRepository;

    @Override
    public void save(User user) {
        user.setId(UUID.randomUUID().toString());
        System.out.println(user);
        userRepository.save(user);
    }

    @Override
    public User login(String username, String password) {
        return userRepository.login(username,password);
    }

    @Override
    public List<User> findAll() {
        return userRepository.findAll();
    }
}
